import { Component, OnInit } from '@angular/core';
import {ActivatedRoute, Params} from "@angular/router";
import {BackApiService} from "../back-api.service";
import { Location } from '@angular/common';
import {MdDialog} from "@angular/material";
import {SimplePendingTask} from "../../shared/PendingTask";
import {ResultDialogComponent} from "../../shared/result-dialog/result-dialog.component";

@Component({
  selector: 'app-progressing-task',
  templateUrl: './progressing-task.component.html',
  styleUrls: ['./progressing-task.component.scss']
})
export class ProgressingTaskComponent implements OnInit {

  constructor(
    private _router: ActivatedRoute,
    private _location: Location,
    private _backApiService: BackApiService,
    private _dialog: MdDialog
  ) { }

  pendingTask: SimplePendingTask;

  ngOnInit() {
    // get the route path info
    this._router.params
      .switchMap((parmas: Params) =>

        this._backApiService.getProgressing(parmas['id'])
      )
      .subscribe((pendingtask) => this.pendingTask = pendingtask);
  }

  goBack(): void {
    this._location.back();
  }


  // 状态修改
  modifiesStatus(): void {
    this._dialog.open(ResultDialogComponent);
  }


  //noinspection JSMethodCanBeStatic
  viewerChange(event): void {
    console.log(event);
  }

}
